package com.chart.web.controller.wx;

import com.chart.common.constant.Constants;
import com.chart.common.core.domain.AjaxResult;
import com.chart.common.core.domain.entity.SysUser;
import com.chart.common.core.domain.model.LoginBody;
import com.chart.framework.web.service.SysLoginService;
import com.chart.system.service.ISysUserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
@RestController
@RequestMapping
public class WxController {

    @Autowired
    private ISysUserService userService;

    @Autowired
    private SysLoginService loginService;

    /**
     * 关注公众号
     * @param phoneNum
     * @return
     */
    @GetMapping("/wechat/getSecondaryTicket")
    public HashMap<Object, Object> generateQrcode(String phoneNum) {
        HashMap<Object, Object> map = null;
        try {
            map = userService.generateUserQrcode(phoneNum);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        return map;
    }


    /**
     * 生成登录的二维码
     * @return
     */

    @GetMapping("/wechat/getSecondaryTickets")
    public HashMap<Object, Object> generateQrcodes() {
        HashMap<Object, Object> map = null;
        try {
            map = userService.generateUserQrcodes();
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        return map;
    }



}
